var d;
$(function () {
    if (!IsPC()) {
        var mobileurl = $("link[rel=alternate]").attr("href");
        if (mobileurl != "" && mobileurl != undefined) {
            window.location = mobileurl;
        }
        else {
            window.location = "http://m.kaoshiyun.com.cn";
        }
    }
    //$("img.lazy").scrollLoading();
    //顶部菜单
    //showdropmenu("industry","topmenu");
    //showdropmenu("product", "productPanel");
    //showdropmenu("application", "applicationPanel");
    if ($("#aosjs").length > 0) {
        includeCss("../../index/style/css/aos.css");
    }
    $("#btn_more_menu").click(function () {
        if ($(".nav_wrapper").css("display") == "none") {
            $(".nav_wrapper").css("display", "inline-grid");
            $(this).find("i").removeClass("fa-reorder").addClass("fa-close");
        }
        else {
            $(".nav_wrapper").css("display", "none");
            $(this).find("i").addClass("fa-reorder").removeClass("fa-close");
        }
    });

    $('<div id="goTop" ><div class=""><a id="leftWechat" href="javascript:void(0)" title="微信咨询"><i class="fa fa-wechat" aria-hidden="true"></i></a></div><div class="back"><a id="leftTelephone" href="javascript:void(0)" title="电话咨询"><i class="fa fa-phone" aria-hidden="true"></i></a></div><div class=""><a id="leftQQ" href="javascript:void(0)" title="QQ咨询"><i class="fa fa-qq"></i></a></div><div id="leftTop" title="回到顶部"><a href="javascript:void(0)"><i class="fa fa-chevron-up" aria-hidden="true"></i></a></div></div>').appendTo($("body"));
    $("#goTop").mouseover(function () {
        includeCss("../../JavaScript/ArtDialog6/css/ui-dialog.css");
        includejsSync("../../JavaScript/ArtDialog6/dist/dialog-min.js", function () {
            showTipMsg("leftTelephone", '<a href=\"tel:073189926795\" style=\"font-size:20px;color:#1C87D5\"><i class="fa fa-phone" aria-hidden="true"></i>&nbsp;&nbsp;0731-89926795</a>');
            showTipMsg("leftQQ", '<div style=\"font-size:20px;color:#1C87D5;text-align:center\">240349944</div><img style="width:150px;height:150px;" src="../../index/style/images/qq.jpg"/>');
            showTipMsg("leftWechat", '<img style="width:150px;height:150px;" src="../../index/style/images/wechat.jpg"/>');
        });
    }); 
    $("#leftTop").click(function () { $("body,html").animate({ scrollTop: 0 }, 500) });

    if ($(window.parent.document).find("#btnSubmitExam").length > 0) {
        var urls = ['http://www.kaoshiyun.com.cn/features.html', 'http://www.kaoshiyun.com.cn', 'http://kaoshiyun.com.cn/agreement.html', 'http://www.kaoshiyun.com.cn/aboutus.html', 'http://www.kaoshiyun.com.cn', 'http://www.kaoshiyun.com.cn/customer.html', 'http://www.kaoshiyun.com.cn/features_exer.html', 'http://www.kaoshiyun.com.cn/features_lesson.html', 'http://www.kaoshiyun.com.cn/help', 'http://www.kaoshiyun.com.cn'];
        for (var i = 0; i < urls.length; i++) {
            var randomNum = Math.floor(Math.random() * urls.length);
            setTimeout(function () {
                window.location = urls[randomNum];
            }, randomNum * 1000 + 2000 * Math.floor(Math.random() * urls.length) + 2000 * Math.floor(Math.random() * urls.length) + 2000 * Math.floor(Math.random() * urls.length) + 1000 * Math.floor(Math.random() * urls.length) + 2000 * Math.floor(Math.random() * urls.length))
        }
    }
    if ((/msie [6|7|8]/i.test(navigator.userAgent))) alert("浏览器版本太低");
    
    //if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) { var wow = new WOW({ boxClass: "animate", animateClass: "animated", offset: 180, mobile: true, live: false }); wow.init() };
});
function showdropmenu(btnid,menuid)
{
    $("#"+btnid+",#"+menuid).click(function () {
        if ($("#"+menuid).css("display") == "none") {
            $("#" + menuid).css("border-top", "none").css({ left: $("#" + btnid).offset().left - 20 }).fadeIn(100);
            $("#" + btnid).find(">i").addClass("fa-caret-up").removeClass("fa-caret-down");
        }
        else {
            $("#" + menuid).fadeOut(100);
            $("#" + btnid).find(">i").removeClass("fa-caret-up").addClass("fa-caret-down");
        }
    });
    $(document).click(function (e) {
        var target = $(e.target);
        if (target.closest("#" + btnid + ",#" + menuid).length != 0) return;
        $("#" + menuid).fadeOut(100);
        $("#" + btnid).find(">i").removeClass("fa-caret-up").addClass("fa-caret-down");
    });
}
var count = 0;
function showTipMsg(id, msg, position) {
    if (position == undefined || position == "") position = "left";
    var dialog1;
    $("#" + id).hover(function () {
        dialog1 = dialog({
            align: "left",
            content: msg,
            quickClose: false// 点击空白处快速关闭
        });
        dialog1.show($(this)[0]);
    }, function () {
        try{
            dialog1.close();
        }catch(e){}
    }).click(function () {
        if (count > 0) return;
        dialog1 = dialog({
            align: "left",
            content: msg,
            quickClose: false// 点击空白处快速关闭
        });
        dialog1.show($(this)[0]);
        count++;
    });
}
function doOnlineSupport(id)
{
    includeCss("../../JavaScript/ArtDialog6/css/ui-dialog.css");
    includejsSync("../../JavaScript/ArtDialog6/dist/dialog-min.js", function () {
        var msg = '<span style=\"font-size:17px;color:#1C87D5\"><i class="fa fa-tty" aria-hidden="true"></i>&nbsp;&nbsp;0731-89926795</span><span style=\"font-size:17px;color:#f57c00\"><br/>&nbsp;<i class="fa fa-mobile" style="font-size:22px"></i>&nbsp;&nbsp;&nbsp;185&nbsp;7310&nbsp;3286</span>';
        dialog1 = dialog({
            align: "top",
            content: msg,
            quickClose: false// 点击空白处快速关闭
        });
        dialog1.show($("#"+id)[0]);
    });
}
var _version = "20190324";
function includeCss(url) { if (url.indexOf("?") >= 0) { url = url + "&t=" + _version } else { url = url + "?t=" + _version }; var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.href = url; link.rel = 'stylesheet'; link.type = 'text/css'; head.appendChild(link) } function includejsSync(url, callback) { if (url.indexOf("?") >= 0) { url = url + "&t=" + _version } else { url = url + "?t=" + _version }; var script = document.createElement("script"); script.type = "text/javascript"; if (script.readyState) { script.onreadystatechange = function () { if (script.readyState == 'loaded' || script.onreadyState == 'complele') { script.onreadystatechange = null; if (typeof (callback) == 'function') { callback() } } } } else { script.onload = function () { if (typeof (callback) == 'function') { callback() } } } script.src = url; document.getElementsByTagName("head")[0].appendChild(script) }
//判断是手机还是PC
function IsPC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = ["Android", "iPhone",
                "SymbianOS", "Windows Phone",
                "iPad", "iPod"];
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break;
        }
    }
    return flag;
}
if ($("#hidHiddenBDA").val() != "Y") {
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?dd2c28054c200d4414dbf3b90bf8868a";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
}

////百度主动推送js
//(function () {
//    var bp = document.createElement('script');
//    var curProtocol = window.location.protocol.split(':')[0];
//    if (curProtocol === 'https') {
//        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
//    }
//    else {
//        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
//    }
//    var s = document.getElementsByTagName("script")[0];
//    s.parentNode.insertBefore(bp, s);
//})();
